﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using DiscoveryLogic.DataServices.DataSources;
using System.Windows.Media;

namespace DiscoveryLogic.UI.Layouts.Controls
{
    public partial class MiniBillGraph : UserControl
    {
        BillPaymentHistory billPaymentHistory;

        public MiniBillGraph()
        {
            InitializeComponent();
        }

        public MiniBillGraph(List<BillPayment> history, string payee, int id)
        {
            InitializeComponent();

            BillPaymentHistory billHistory = new BillPaymentHistory(history, payee, id);
            billPaymentHistory = billHistory;
        }

        #region Mouse Events

        protected void Graph_MouseEnter(object sender, MouseEventArgs e)
        {
            ((FrameworkElement)sender).Cursor = Cursors.Hand;
        }

        protected void Graph_MouseLeave(object sender, EventArgs e)
        {
            ((FrameworkElement)sender).Cursor = Cursors.Arrow;
        }

        #endregion

        private void Rectangle_Loaded(object sender, RoutedEventArgs e)
        {
            //set up gradient stops
            FrameworkElement rect = sender as FrameworkElement;
            BillPayment billPayment = rect.DataContext as BillPayment;
            
            GradientStop barGradient0 = rect.FindName("BarGradient0") as GradientStop;
            barGradient0.Color = billPayment.GS0Color;

            GradientStop barGradient1 = rect.FindName("BarGradient1") as GradientStop;
            barGradient1.Color = billPayment.GS1Color;

            GradientStop barGradient2 = rect.FindName("BarGradient2") as GradientStop;
            barGradient2.Color = billPayment.GS2Color;

            GradientStop barGradient3 = rect.FindName("BarGradient3") as GradientStop;
            barGradient3.Color = billPayment.GS3Color;

            GradientStop barGradient4 = rect.FindName("BarGradient4") as GradientStop;
            barGradient4.Color = billPayment.GS4Color;
        }
    }
}
